package com.xyy.saas.payment.pojo.param;

import com.xyy.saas.payment.exception.PaymentException;
import com.xyy.saas.payment.manage.cores.enums.ResultCodeEnum;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import java.util.Date;

@Data
public class AccountTransferParam {
    /**
     * 业务线标识
     */
    private String businessIdType;
    /**
     * 出账方
     */
    private String outAccountId;
    /**
     * 入账方
     */
    private String inAccountId;
    /**
     * 金额
     */
    private Integer amount;
    /**
     * 业务单号，支付平台支付单号
     */
    private String businessOrderNo;
    /**
     * 备注
     */
    private String remark;

    //--------------查询条件---------------

    /**
     * 状态
     */
    private String status;
    /**
     * 开始时间，yyyy-MM-dd HH:mm:ss
     */
    private Date startTime;
    /**
     * 结束时间，yyyy-MM-dd HH:mm:ss
     */
    private Date endTime;

    /**
     * 参数校验
     */
    public void checkParam() throws PaymentException {
        if(StringUtils.isBlank(businessIdType)) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "业务线不能为空");
        }

        if(StringUtils.isBlank(outAccountId)) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "出账方不能为空");
        }

        if(StringUtils.isBlank(inAccountId)) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "入账方不能为空");
        }

        if(amount == null || amount <= 0) {
            throw new PaymentException(ResultCodeEnum.PARAM_ERROR.getCode(), "转账金额需>0");
        }
    }
}
